/*
*for -in语法：用于遍历数组或对象的属性的循环

*/
function fn() {
    //自定义的数组
    let arr = [1, 2, 3, 4, 5]
    //数组的求和
    let sum = 0
    for (const key in arr) {
        //key类似于数组的下标
        let element = arr[key]
        sum += element
        console.log(key + ':' + arr[key])
    }
    console.log(sum)
}

function fn1() {

    //学生队形
    let student = {
        id: 'tx01',
        name: 'alen',
        gender: '女',
        age: 19,
    }
    for (let i in student) {
        //i类似于对象的属性
        console.log(i + ':' + student[i])
    }
}
fn1()